package com.huawei.crm.sample.domain.product.model.aggragate;

import com.huawei.crm.sample.domain.product.exceptions.ProductException;
import java.math.BigDecimal;
import lombok.Data;

@Data
public class Product {
    private String productId;
    private String name;
    private int stock;
    private BigDecimal price;

    public Product(String productId, String name, int stock, BigDecimal price) {
        this.productId = productId;
        this.name = name;
        this.stock = stock;
        this.price = price;
    }

    public void decreaseStock(int quantity) {
        if (quantity > stock) {
            throw new ProductException("库存不足");
        }
        this.stock -= quantity;
    }
} 